package com.example.gokchinesefoodmappcdev.controller;

import com.example.gokchinesefoodmappcdev.entity.dto.MarketingDTO;
import com.example.gokchinesefoodmappcdev.service.MarketingService;
import com.example.gokchinesefoodmappcdev.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rest/marketing")
public class MarketingController {
    @Autowired
    private MarketingService marketingService;

    /**
     * 新增营销商品信息
     * @param marketingDTO
     * @return
     */
    @RequestMapping("/marketingManagement/save")
    public ResultData insertMarketingCommodityAndMarketingPicture(MarketingDTO marketingDTO) {
        ResultData resultData = marketingService.insertMarketingCommodityAndMarketingPicture(marketingDTO);
        return resultData;
    }

    /**
     * 营销商品列表查看
     * @return
     */
    @RequestMapping("/marketingManagement/list")
    public ResultData selectMarketing() {
        ResultData resultData = marketingService.selectMarketing();
        return resultData;
    }
    @RequestMapping("/marketingPicture/remove/{id}")
    public ResultData deleteMarketingPictureById(Integer id) {
        ResultData resultData = marketingService.deleteMarketingPictureById(id);
        return resultData;
    }

    /**
     * 删除营销商品
     * @param id
     * @return
     */
    @RequestMapping("/marketingCommodity/remove/{id}")
    public ResultData deleteMarketingCommodById(Integer id) {
        ResultData resultData = marketingService.deleteMarketingCommodById(id);
        return resultData;
    }
}
